<?php

namespace app\admin\controller;

use think\Controller;
use Util\SysDb;
use think\Db;
class Params extends Controller
{
    public function Paramslist()
    {
        $page = trim(input('param.pageNo'));
        $limit = trim(input('param.pageSize'));
        $tol = (intval($page) - 1) * $limit;
        $list = DB::name("sys_params")->order("create_time desc")->limit($tol, $limit)->select();
        $this->db = new SysDb();
        $count = $this->db->table('sys_params')->count();
        $data = array();
        array_push($data, $list);
        array_push($data, $count);
        exit(json_encode(['code' => 1, 'message' => 'succ', "result" => $data]));
    }

    public function updateParams(){
        $value = trim(input('param.value'));
        $id=trim(input('param.id'));
        $this->db = new SysDb();
        $admin=$this->db->table('sys_params')->where(['id' => $id])->item();
        $admin['value']= $value;
        $count = $this->db->table('sys_params')->where(['id' => $id])->update($admin);
        if($count){
            exit(json_encode(['code' => 1, 'message' => 'succ', "result" => "添加成功"]));
        }
    }
    
}

